<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/> 

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta name="decorator" content="default" />
</head>
<body>
<div class="row row-default border-ra2">
	<div class="col-sm-12">	
		<div class="row row-content">
			<div class="col-xs-12">
				<div class="table-responsive">
					<form class="form-horizontal">
						<div class="tabbable">
						 <ul class="nav nav-tabs padding-16">
								<li class="active">
									<a data-toggle="tab" href="#">
										<i class="blue icon-key bigger-125"></i>
										修改密码
									</a>
								</li>
							</ul>

							<div class="tab-content profile-edit-tab-content">
								<div id="" class="">
									<div class="space-4"></div>
									<div class="form-group">
										<label class="col-sm-3 control-label no-padding-right" for="form-field-pass1">
										<input type="hidden" id="empId" value="<shiro:principal property="uuid"></shiro:principal>">
										新密码 
										</label>
										<div class="col-sm-9">
											<input type="password" id="newPwd"/>
											<span class="help-inline text-danger" id="newPwdError"></span>
										</div>
									</div>
									<div class="space-4"></div>
									<div class="form-group">
										<label class="col-sm-3 control-label no-padding-right" for="form-field-pass2">
										确认新密码</label>

										<div class="col-sm-9">
											<input type="password" id="newPwds"/>
											<span class="help-inline text-danger" id="newPwdsError"></span>
										</div>
									</div>
									<div class="space-4"></div>
								</div>
							</div>
						</div>

						<div class="clearfix form-actions">
							<div class="col-md-offset-5 col-md-9">
								<button class="btn btn-info" type="button" id="updatePassWord">
									<i class="icon-ok bigger-110"></i>
									修改
								</button>

								&nbsp; &nbsp;
								<button class="btn" type="reset">
									<i class="icon-undo bigger-110"></i>
									重置
								</button>
							</div>
						</div>
					</form>	
				</div>
			</div>
		</div>					
	</div>
</div>
<script type="text/javascript">

	$(document).ready(function(){
		$("#updatePassWord").on("click",function(){
			updatePassWord();
		})
	});
	//修改密码
	function updatePassWord(){	
		
	 	//得到原密码是否正确
		var newPwd = $("#newPwd").val();
		var newPwdS= $("#newPwds").val();
		
		//验证密码的正则
		 var reg = /^([0-9a-zA-Z]){6,16}$/;
		 if(!reg.test(newPwd))  
	       {
			 $("#newPwdError").html("请输入6-16字母或数字");
	         return;
	       }
		 if(!reg.test(newPwdS))  
	       {
			 $("#newPwdError").html("");
			 $("#newPwdsError").html("请输入6-16字母或数字");
	         return;
	       }	
		 if(newPwd!=newPwdS){
			 $("#newPwdError").html("");
			 $("#newPwdsError").html("");			
			 $("#newPwdsError").html("您两次输入的新密码不一致");
			 return;
		 }
		 
		 var empId = $("#empId").val();
		 Otod.ajax({
			 url:"${ctx}/sys/emp/updatePassword.do",
			 data:{uuid:empId,password:newPwd},
			 type:'GET',
			 successFn:function(data){
				Otod.Msg.info("修改密码成功");
			 }
		 })
		 
	}
</script>
</body>
